package com.zzz.java8;

import javax.xml.crypto.Data;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.temporal.ChronoField;
import java.time.temporal.ChronoUnit;
import java.time.temporal.Temporal;
import java.time.temporal.TemporalAdjuster;

/**
 * @author zhuzhizun
 * @date 2021/8/13
 */
public class NextWorkingDay implements TemporalAdjuster {
    @Override
    public Temporal adjustInto(Temporal temporal) {
        // 获取今天是周几
        DayOfWeek week = DayOfWeek.of(temporal.get(ChronoField.DAY_OF_WEEK));
        // 正常情况加1
        int addDay = 1;
        // 星期五加3
        if (week == DayOfWeek.FRIDAY){
            addDay = 3;
        }
        // 星期六加2
        if (week == DayOfWeek.SATURDAY){
            addDay = 2;
        }

        return temporal.plus(addDay, ChronoUnit.DAYS);

    }
}
